/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.documents.main.action;

import com.documents.common.core.PageBean;
import com.documents.common.core.action.BaseActionSupport;
import com.documents.pojo.ContentType;
import com.documents.pojo.Institution;
import com.documents.pojo.KnowledgeArea;
import com.documents.service.knowledge.ContentTypeService;
import com.documents.service.knowledge.InstitutionService;
import com.documents.service.knowledge.KnowledgeAreaService;
import java.util.List;
import org.apache.struts2.interceptor.ServletRequestAware;

/**
 *
 * @author Administrator
 */
public class KnowledgeAreaAction extends BaseActionSupport implements ServletRequestAware{
     private static final long serialVersionUID = 1003L;
    private KnowledgeAreaService knowledgeAreaService;

    private List<KnowledgeArea>  allArea;  
  
    private int page=1;
    private PageBean pageBean;
    private int pageSize = 20;
    private KnowledgeArea area; 

   
    private String actionURI;

    public String getActionURI() {
        return actionURI;
    }

    public void setActionURI(String actionURI) {
        this.actionURI = actionURI;
    }

    public List<KnowledgeArea> getAllArea() {
        return allArea;
    }

    public void setAllArea(List<KnowledgeArea> allArea) {
        this.allArea = allArea;
    }

    public KnowledgeArea getArea() {
        return area;
    }

    public void setArea(KnowledgeArea area) {
        this.area = area;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public PageBean getPageBean() {
        return pageBean;
    }

    public void setPageBean(PageBean pageBean) {
        this.pageBean = pageBean;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public KnowledgeAreaService getKnowledgeAreaService() {
        return knowledgeAreaService;
    }

    public void setKnowledgeAreaService(KnowledgeAreaService productService) {
        this.knowledgeAreaService = productService;
    }
       

    
    
    public String main() throws Exception {
        return "success";
    }

    public String top() throws Exception {
        this.allArea = knowledgeAreaService.findAll();
        return "success";
    }

    public String arealist() throws Exception {

        pageBean = knowledgeAreaService.getPageBean(page, pageSize, area);

        return SUCCESS;
    }
    
     public void areaDeleteById() {
        
        knowledgeAreaService.delById(area.getId());
    }

    public String addAreaInput() throws Exception {
        actionURI = "areasave";
        return SUCCESS;
    }

    public String areasave() throws Exception {
        knowledgeAreaService.save(area);
        return SUCCESS;
    }
    
     public String update() throws Exception {
        knowledgeAreaService.update(area);
        return SUCCESS;
    }
    
    public String updateInput() throws Exception {
        actionURI = "areaUpdate";
        area = this.knowledgeAreaService.get(area.getId());
        if(area == null)
            return ERROR;
        else
            return SUCCESS;
    }
    

   
    
}
